package com.leetcode.周赛.第231场;

/**
 * @author: xiaomi
 * @date: 2021/3/7
 * @description:
 */
public class A_5697_检查二进制字符串字段 {

    public static void main(String[] args) {
        String s = "11001";
        System.out.println(checkOnesSegment(s));

    }

    /***
     * s[0] 为 '1'
     * @param s
     * @return
     */
    public static boolean checkOnesSegment(String s) {
        char[] chars = s.toCharArray();
        int len = chars.length;
        int end = 1;
        for (; end < len; end++) {
            if (chars[end] == '0') {
                break;
            }
        }
        //此时  [end] =0
        if (end == len) {
            return true;
        }
        end++;
        for (; end < len; end++) {
            if (chars[end] == '1') {
                return false;
            }
        }
        return true;
    }
}
